//
//  MOWaitDoDetail_IdeaViewCell.m
//  MobileOffice
//
//  Created by 冰冰 on 2019/6/7.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#import "MOWaitDoDetail_IdeaViewCell.h"

@interface MOWaitDoDetail_IdeaViewCell ()


@property(nonatomic,strong)UILabel *resultNameLabel;
@property(nonatomic,strong)UILabel *dutyLabel;
@property(nonatomic,strong)UILabel *depyNameLabel;
@property(nonatomic,strong)UILabel *suggestionLabel;
@property(nonatomic,strong)UILabel *dateTimeLabel;
@property(nonatomic,strong)UILabel *processModeLabel;
@property(nonatomic,strong)UILabel *declareLabel;

@property(nonatomic,strong)UIView *lineOView;
@property(nonatomic,strong)UIView *lineView;


@end


@implementation MOWaitDoDetail_IdeaViewCell

+(instancetype)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    //NSString *ID = [NSString stringWithFormat:@"Cell%ld%ld",(long)[indexPath section],(long)[indexPath row]];
    NSString *ID = @"MOWaitDoDetail_IdeaViewCell";
    MOWaitDoDetail_IdeaViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil){
        cell = [[MOWaitDoDetail_IdeaViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell creatView];
    }
    return cell;
}


-(void)creatView
{
    self.nameButton = [[UIButton alloc]initWithFrame:CGRectMake(17, 0, 100, kHConversions(54))];
    [self.nameButton setTitleColor:KBlackColor_2A2A2A forState:UIControlStateNormal];
    self.nameButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
    [self.nameButton setContentHorizontalAlignment:(UIControlContentHorizontalAlignmentLeft)];
    [self addSubview:self.nameButton];
    
    self.rightButton = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-100 - 17, 0, 100, kHConversions(54))];
    self.rightButton.titleLabel.font = FONT_SIZE(15);
    [self.rightButton SG_imagePositionStyle:(SGImagePositionStyleRight) spacing:10];
    [self.rightButton setTitleColor:KBlackColor_2A2A2A forState:UIControlStateNormal];
//    [self.rightButton setBackgroundColor:[UIColor redColor]];
    [self.rightButton setContentHorizontalAlignment:(UIControlContentHorizontalAlignmentRight)];
    [self addSubview:self.rightButton];
    
    self.lineOView = [[UIView alloc]initWithFrame:CGRectMake(0, self.rightButton.bottom, SCREEN_WIDTH, 1)];
    self.lineOView.backgroundColor = KGrayColor_ededed;
    [self addSubview:self.lineOView];
    
    
    NSArray *titleArr1 = @[@"人员姓名",@"部门名称"];
    CGFloat labelHeight = 13;
    CGFloat Y1 = self.nameButton.bottom;
    for (int i = 0; i<titleArr1.count; i++) {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, self.nameButton.bottom + 1  + 17.5*(i+1)+labelHeight*i, SCREEN_WIDTH-60, labelHeight)];
        label.font = FONT_SIZE(13);
        label.textColor = KBlackColor_919395;
        label.text = titleArr1[i];
        [self addSubview:label];
        Y1 = label.bottom;
        
        if (i==0) {
            self.resultNameLabel = label;
        }else{
            self.depyNameLabel = label;
        }
    }
    
    self.lineView = [[UIView alloc]initWithFrame:CGRectMake(16, Y1 + 13, SCREEN_WIDTH - 32, 1)];
    self.lineView.backgroundColor = KGrayColor_ededed;
    [self addSubview:self.lineView];
    
    NSArray *titleArr2 = @[@"审批日期",@"审批说明",@"岗位职责",@"处理意见",@"处理方式"];
    CGFloat Y2 = 0;
    for (int i = 0; i<titleArr2.count; i++) {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, self.lineView.bottom + 17.5*(i+1)+labelHeight*i, SCREEN_WIDTH-60, labelHeight)];
        label.font = FONT_SIZE(13);
        label.textColor = KBlackColor_919395;
        label.text = titleArr2[i];
        [self addSubview:label];
        Y2 = label.bottom;
        
        if (i==0) {
            self.dateTimeLabel = label;
        }else if (i==1){
            self.declareLabel = label;
        }else if (i==2){
            self.dutyLabel = label;
        }else if (i==3){
            self.suggestionLabel = label;
        }else if (i==4){
            self.processModeLabel = label;
        }
    }
    
}


-(void)setModel:(MOWaitDoDetail_IdeaModel *)model
{
    if ([model.openStatus integerValue]==1) {
        self.resultNameLabel.hidden = NO;
        self.dutyLabel.hidden = NO;
        self.depyNameLabel.hidden = NO;
        self.suggestionLabel.hidden = NO;
        self.dateTimeLabel.hidden = NO;
        self.processModeLabel.hidden = NO;
        self.declareLabel.hidden = NO;
        self.lineView.hidden = NO;
        self.lineOView.hidden = NO;
    }else{
        self.resultNameLabel.hidden = YES;
        self.dutyLabel.hidden = YES;
        self.depyNameLabel.hidden = YES;
        self.suggestionLabel.hidden = YES;
        self.dateTimeLabel.hidden = YES;
        self.processModeLabel.hidden = YES;
        self.declareLabel.hidden = YES;
        self.lineView.hidden = YES;
        self.lineOView.hidden = YES;
    }
    
    [self.nameButton setTitle:@"审批人:" forState:UIControlStateNormal];
    [self.rightButton setTitle:model.resultName forState:UIControlStateNormal];
    if ([model.openStatus integerValue]==1) {
        [self.rightButton setImage:IMAGE(@"top_notice") forState:UIControlStateNormal];
    }else{
        [self.rightButton setImage:IMAGE(@"down_notice") forState:UIControlStateNormal];
    }
    [self.rightButton SG_imagePositionStyle:(SGImagePositionStyleRight) spacing:10];
    
    
    NSString *str1 = [NSString stringWithFormat:@"%@  %@",@"人员姓名",model.resultName];
    self.resultNameLabel.attributedText = [NSString contentString:str1 subString:model.resultName subColor:KBlackColor_222222 subFont:FONT_SIZE(13)];
    
    NSString *str2 = [NSString stringWithFormat:@"%@  %@",@"部门名称",model.depyName];
    self.depyNameLabel.attributedText = [NSString contentString:str2 subString:model.depyName subColor:KBlackColor_222222 subFont:FONT_SIZE(13)];
    
    NSString *str3 = [NSString stringWithFormat:@"%@  %@",@"岗位职责",model.duty];
    self.dutyLabel.attributedText = [NSString contentString:str3 subString:model.duty subColor:KBlackColor_222222 subFont:FONT_SIZE(13)];
    
    NSString *str4 = [NSString stringWithFormat:@"%@  %@",@"处理意见",model.suggestion];
    self.suggestionLabel.attributedText = [NSString contentString:str4 subString:model.suggestion subColor:KBlackColor_222222 subFont:FONT_SIZE(13)];
    
    NSString *str5 = [NSString stringWithFormat:@"%@  %@",@"审批日期",model.dateTime];
    self.dateTimeLabel.attributedText = [NSString contentString:str5 subString:model.dateTime subColor:KBlackColor_222222 subFont:FONT_SIZE(13)];
    
    NSString *str6 = [NSString stringWithFormat:@"%@  %@",@"处理方式",model.processMode];
    self.processModeLabel.attributedText = [NSString contentString:str6 subString:model.processMode subColor:KBlackColor_222222 subFont:FONT_SIZE(13)];
    
    NSString *str7 = [NSString stringWithFormat:@"%@  %@",@"审批说明",model.declare];
    self.declareLabel.attributedText = [NSString contentString:str7 subString:model.declare subColor:KBlueColor_2C94FF subFont:FONT_SIZE(13)];
    
}



+ (CGFloat)heightForMOWaitDoDetail_IdeaViewCellAndModel:(MOWaitDoDetail_IdeaModel *)model
{
    CGFloat YY = 0;
    
    NSArray *titleArr1 = @[@"人员姓名",@"部门名称"];
    CGFloat labelHeight = 13;
    CGFloat Y1 = 0;
    for (int i = 0; i<titleArr1.count; i++) {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, 17.5*(i+1)+labelHeight*i, SCREEN_WIDTH-60, labelHeight)];
        Y1 = label.bottom;
    }
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(16, Y1 + 13, SCREEN_WIDTH - 32, 1)];
    
    NSArray *titleArr2 = @[@"审批日期",@"审批说明",@"岗位职责",@"处理意见",@"处理方式"];
    CGFloat Y2 = 0;
    for (int i = 0; i<titleArr2.count; i++) {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, lineView.bottom + 17.5*(i+1)+labelHeight*i, SCREEN_WIDTH-60, labelHeight)];
        Y2 = label.bottom;
    }
    
    YY = Y2 + 20;
    
    if ([model.openStatus integerValue]==1) {
        return YY + kHConversions(53);
    }else{
        return kHConversions(53);
    }
    
}


@end
